<template>
  <view class="business-container">
    <!-- 页面标题 -->
    <view class="page-header">
      <view class="header-content">
        <view class="page-title">商机管理</view>
        <view class="select-group-btn" @click="showGroupSelector">
          <text>{{ selectedGroup ? currentGroup.label : '请选择集团单位' }}</text>
          <u-icon name="arrow-down-fill" size="14" color="#ffffff"></u-icon>
        </view>
      </view>
      <!-- 波浪背景装饰 -->
      <view class="wave-box">
        <view class="wave wave-1"></view>
        <view class="wave wave-2"></view>
      </view>
    </view>

    <!-- 内容区域 -->
    <view class="content-area">
      <!-- 集团信息概览卡片 -->
      <view class="group-info-card animate-scale-up" v-if="selectedGroup">
        <view class="card-header">
          <view class="card-title">
            <u-icon name="home" size="22" color="#007aff"></u-icon>
            <text>{{ currentGroup.label }}</text>
          </view>
          <view class="card-badge" :class="getBadgeClass(currentGroup.industry)">
            {{ currentGroup.industry || '未分类' }}
          </view>
        </view>
        
        <view class="info-grid">
          <view class="info-row">
            <view class="info-item">
              <text class="info-label">客户编码</text>
              <text class="info-value">{{ currentGroup.code || '暂无' }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">县区</text>
              <text class="info-value">{{ currentGroup.district || '暂无' }}</text>
            </view>
          </view>
          <view class="info-row">
            <view class="info-item">
              <text class="info-label">客户经理</text>
              <text class="info-value">{{ currentGroup.manager || '暂无' }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">行业属性</text>
              <text class="info-value">{{ currentGroup.industry || '暂无' }}</text>
            </view>
          </view>
        </view>
      </view>
      
      <!-- 未选择集团时的提示 - 移到这里，跟集团信息卡片位置一致 -->
      <view class="empty-notice-container animate-scale-up" v-if="!selectedGroup">
        <view class="group-info-card empty-notice-card">
          <view class="empty-notice">
            <image src="/static/select_group.png" mode="aspectFit" class="empty-image"></image>
            <view class="empty-text">请选择一个集团单位进行管理</view>
            <u-button type="primary" @click="showGroupSelector" class="select-btn">选择集团单位</u-button>
          </view>
        </view>
      </view>
      
      <!-- 功能模块入口 始终显示 -->
      <view class="module-list animate-slide-up">
        <view class="module-item" @click="goToBasicInfo">
          <view class="module-icon module-icon-blue">
            <u-icon name="account" color="#ffffff" size="28"></u-icon>
          </view>
          <view class="module-info">
            <view class="module-title">基础信息</view>
            <view class="module-desc">管理集团单位的基础人员、网络信息</view>
          </view>
          <view class="item-right">
            <view class="status-tag" v-if="selectedGroup" :class="moduleStatus.basicInfo ? 'status-complete' : 'status-incomplete'">
              {{ moduleStatus.basicInfo ? '已完善' : '未完善' }}
            </view>
            <u-icon name="arrow-right" color="#c0c4cc" size="28"></u-icon>
          </view>
        </view>

        <view class="module-item" @click="goToMemberFollow">
          <view class="module-icon module-icon-green">
            <u-icon name="calendar" color="#ffffff" size="28"></u-icon>
          </view>
          <view class="module-info">
            <view class="module-title">成员跟进</view>
            <view class="module-desc">管理递送方案时间和政策资费</view>
          </view>
          <view class="item-right">
            <view class="status-tag" v-if="selectedGroup" :class="moduleStatus.memberFollow ? 'status-complete' : 'status-incomplete'">
              {{ moduleStatus.memberFollow ? '已完善' : '未完善' }}
            </view>
            <u-icon name="arrow-right" color="#c0c4cc" size="28"></u-icon>
          </view>
        </view>

        <view class="module-item" @click="goToITExpansion">
          <view class="module-icon module-icon-orange">
            <u-icon name="server-fill" color="#ffffff" size="28"></u-icon>
          </view>
          <view class="module-info">
            <view class="module-title">信息化拓展</view>
            <view class="module-desc">管理五大类信息化产品拓展计划</view>
          </view>
          <view class="item-right">
            <view class="status-tag" v-if="selectedGroup" :class="moduleStatus.itExpansion ? 'status-complete' : 'status-incomplete'">
              {{ moduleStatus.itExpansion ? '已完善' : '未完善' }}
            </view>
            <u-icon name="arrow-right" color="#c0c4cc" size="28"></u-icon>
          </view>
        </view>
      </view>
    </view>
    
    <!-- 集团选择弹窗 -->
    <view v-if="showGroupPopup" class="custom-popup-mask" @click="onMaskClick">
      <view class="custom-popup" @click.stop>
        <view class="popup-content-wrap">
          <!-- 弹窗头部 -->
          <view class="popup-header">
            <text class="popup-title">选择集团单位</text>
            <view class="popup-close-btn" @click="onPopupClose">
              <u-icon name="close" size="20" color="#666"></u-icon>
            </view>
          </view>
          
          <!-- 搜索框 -->
          <view class="popup-search-box">
            <u-search 
              v-model="searchKeyword" 
              :show-action="false" 
              placeholder="搜索集团名称或行业" 
              shape="round"
              height="32px"
              @input="onInput"
              @change="onInput"
              @clear="onInput"
              @search="onSearch"
              @custom="onSearch"
            ></u-search>
          </view>
          
          <!-- 行业分类标签 -->
          <view class="popup-tabs">
            <view 
              v-for="(item, index) in industryList" 
              :key="index"
              class="popup-tab-item"
              :class="{'popup-tab-active': activeFilter === index}"
              @click="filterGroups(index, item.value)"
            >{{item.label}}</view>
          </view>
          
          <!-- 列表内容 -->
          <scroll-view scroll-y class="popup-scroll-view">
            <!-- 全部集团 -->
            <view class="popup-list-title">
              <text>全部集团</text>
            </view>
            <view class="popup-group-list">
              <view 
                v-for="(item, index) in filteredGroups" 
                :key="index"
                class="popup-group-item"
                :class="{'selected': selectedGroup === item.code}"
                @click="selectGroup(item)"
              >
                <view class="popup-group-info">
                  <view class="popup-group-name">{{ item.name || item.label }}</view>
                  <view class="popup-group-code">{{ item.code || '未分配编码' }} | {{ item.industry || '未分类' }}</view>
                </view>
                <view v-if="selectedGroup === item.code" class="selected-indicator">
                  <u-icon name="checkmark-circle" size="18" color="#007aff"></u-icon>
                </view>
              </view>
            </view>
            
            <!-- 空状态 -->
            <view v-if="filteredGroups.length === 0" class="popup-empty">
              <u-empty mode="search" text="未找到相关集团"></u-empty>
            </view>
          </scroll-view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 集团选择相关(存储集团编码)
      selectedGroup: "",
      searchKeyword: "",
      searchTimer: null,  // 搜索防抖定时器
      groupOptions: [],
      currentGroup: {},
      filteredGroups: [],
      activeFilter: 0,
      showGroupPopup: false,
      // 行业列表
      industryList: [
        { label: '全部', value: '' },
        { label: '政府机构', value: '政府机构' },
        { label: '教育', value: '教育' },
        { label: '医疗', value: '医疗' }
      ],
      
      // 模块状态
      moduleStatus: {
        basicInfo: false,
        memberFollow: false,
        itExpansion: false
      },
      
      // 基础信息
      basicInfo: {
        totalCount: 0,
        netCount: 0,
        count5G: 0,
        broadbandCount: 0,
        terminal5GCount: 0
      },
      
      // 加载状态
      loading: false
    };
  },
  computed: {
    // 判断是否有基础信息
    hasBasicInfo() {
      return this.basicInfo && 
        (this.basicInfo.totalCount || 
         this.basicInfo.netCount || 
         this.basicInfo.count5G || 
         this.basicInfo.broadbandCount || 
         this.basicInfo.terminal5GCount);
    }
  },
  onLoad(options) {
    // 获取行业列表
    this.getIndustryList();
    
    // 获取集团列表
    this.getGroupList();
    
    // 如果有传入groupCode参数，则自动选择该集团
    if (options && options.groupCode) {
      this.quickSelect(options.groupCode);
    }
    
    // 初始化页面状态
    this.updateModuleStatus();
  },
  onShow() {
    // 如果已选择集团单位，更新模块状态
    if (this.selectedGroup) {
      this.updateModuleStatus();
      this.getGroupDetail();
    }
  },
  created() {
    // 初始化数据
    uni.$on('updatePopup', () => {
      // 处理可能的组件错误
      if (this.showGroupPopup) {
        this.showGroupPopup = false;
        setTimeout(() => {
          this.showGroupPopup = true;
        }, 300);
      }
    });
  },
  beforeDestroy() {
    // 清理事件
    uni.$off('updatePopup');
  },
  methods: {
    // 显示集团选择弹窗
    showGroupSelector() {
      // 确保组件已经初始化
      this.$nextTick(() => {
        setTimeout(() => {
          this.showGroupPopup = true;
        }, 100);
      });
    },
    
    // 弹窗关闭时触发
    onPopupClose() {
      this.showGroupPopup = false;
      this.searchKeyword = "";
      this.filterGroups(this.activeFilter, this.industryList[this.activeFilter]?.value || '');
    },
    
    /**
     * 检查模块状态，判断是否可以进入
     * @param {string} moduleName - 模块名称
     * @return {boolean} - 是否可以进入
     */
    checkModuleStatus(moduleName) {
      if (!this.selectedGroup) {
        uni.showToast({
          title: '请先选择集团单位',
          icon: 'none'
        });
        return false;
      }
      
      // 根据模块类型检查状态
      switch (moduleName) {
        case 'basicInfo':
          // 基础信息模块始终可进入，即使未完善
          return true;
        case 'memberFollow':
          // 成员跟进模块检查基础信息是否已完善
          if (!this.hasBasicInfo) {
            uni.showToast({
              title: '请先完善基础信息',
              icon: 'none'
            });
            return false;
          }
          return true;
        case 'itExpansion':
          // 信息化拓展模块检查
          if (!this.hasBasicInfo) {
            uni.showToast({
              title: '请先完善基础信息',
              icon: 'none'
            });
            return false;
          }
          return true;
        default:
          return true;
      }
    },
    
    /**
     * 导航到基础信息模块
     */
    goToBasicInfo() {
      console.log('goToBasicInfo', this.checkModuleStatus('basicInfo'));
      if (this.checkModuleStatus('basicInfo')) {
        this.navigateToModule('/pages/business/basic');
      }
    },
    
    /**
     * 导航到成员跟进模块
     */
    goToMemberFollow() {
      if (this.checkModuleStatus('memberFollow')) {
        this.navigateToModule('/pages/business/follow/index');
      }
    },
    
    /**
     * 导航到信息化拓展模块
     */
    goToITExpansion() {
      if (this.checkModuleStatus('itExpansion')) {
        this.navigateToModule('/pages/business/expansion/index');
      }
    },
    
    /**
     * 导航到指定模块
     * @param {string} url - 目标页面路径
     */
    navigateToModule(url) {
      if (!this.selectedGroup) {
        uni.showToast({
          title: '请先选择集团单位',
          icon: 'none'
        });
        return;
      }
      
      // 构建完整URL，只携带集团单位编码参数
      const targetUrl = `${url}?groupCode=${this.selectedGroup}`;
      console.log('跳转目标URL:', targetUrl);

      uni.navigateTo({
        url: targetUrl,
        success: () => {
          console.log('成功跳转到:', url);
        },
        fail: (error) => {
          console.error('跳转失败:', error);
          uni.showToast({
            title: '页面跳转失败',
            icon: 'none'
          });
        }
      });
    },
    
    // 按行业筛选集团
    filterGroups(index, industry) {
      this.activeFilter = index;
      
      // 显示加载中
      uni.showLoading({
        title: '筛选中...'
      });
      
      // 显示当前搜索关键词和行业状态
      console.log('当前搜索状态:', {
        searchKeyword: this.searchKeyword,
        activeFilter: this.activeFilter,
        industry: industry
      });
      
      // 构建请求参数
      const params = {
        page: 1,
        limit: 50
      };
      
      // 添加关键词参数 (如果有)
      const trimmedKeyword = this.searchKeyword ? this.searchKeyword.trim() : '';
      if (trimmedKeyword) {
        params.keyword = trimmedKeyword;
        // 添加日志
        console.log('添加搜索关键词:', trimmedKeyword);
      }
      
      // 添加行业参数，仅当选择了非"全部"选项时
      if (index > 0 && industry) {
        params.industry = industry;
      }
      
      console.log('最终请求参数:', JSON.stringify(params));
      
      // 调用接口按行业筛选
      this.$http.sendRequest('zhanke/group_list', 'POST', params).then(res => {
        uni.hideLoading();
        
        if (res.data && res.data.code === 200) {
          const list = res.data.data.list || [];
          console.log('筛选结果数量:', list.length);
          
          // 将接口返回的数据格式化为组件需要的格式
          const filteredList = list.map(item => {
            return {
              value: item.id,
              label: item.name,
              code: item.code,
              district: item.district,
              industry: item.industry,
              industryCode: item.industryCode,
              industryChain: item.industryChain,
              manager: item.manager,
              totalCount: item.totalMembers,
              netCount: item.networkMembers,
              count5G: item.members5G,
              broadbandCount: item.broadbandMembers,
              terminal5GCount: item.terminal5GMembers
            }
          });
          
          // 更新筛选结果
          this.filteredGroups = filteredList;
          
          // 缓存对应行业的选项，以便后续快速筛选
          if (index === 0) {
            this.groupOptions = filteredList;
          }
          
          // 检查是否有匹配结果
          if (filteredList.length === 0 && index !== 0) {
            uni.showToast({
              title: '该行业暂无集团单位',
              icon: 'none'
            });
          }
        } else {
          // 处理API错误
          this.filteredGroups = [];
          uni.showToast({
            title: res.data.msg || '筛选失败',
            icon: 'none'
          });
        }
      }).catch(err => {
        uni.hideLoading();
        console.error('筛选出错：', err);
        uni.showToast({
          title: '筛选请求失败',
          icon: 'none'
        });
        
        // 错误时尝试使用缓存数据
        if (this.groupOptions.length > 0) {
          if (index === 0) {
            this.filteredGroups = this.groupOptions;
          } else if (industry) {
            this.filteredGroups = this.groupOptions.filter(item => item.industry === industry);
          }
        }
      });
    },

    // 获取集团单位列表
    getGroupList() {
      // 显示加载提示
      uni.showLoading({
        title: '加载中...'
      });
      
      // 调用接口获取集团单位列表
      this.$http.sendRequest('zhanke/group_list', 'POST', {
        page: 1,
        limit: 50  // 设置较大的值以获取更多记录
      }).then(res => {
        if (res.data && res.data.code === 200) {
          const list = res.data.data.list || [];
          
          // 将接口返回的数据格式化为组件需要的格式
          this.groupOptions = list.map(item => {
            return {
              value: item.id,
              label: item.name,
              code: item.code,
              district: item.district,
              industry: item.industry,
              industryCode: item.industryCode,
              industryChain: item.industryChain,
              manager: item.manager,
              totalCount: item.totalMembers,
              netCount: item.networkMembers,
              count5G: item.members5G,
              broadbandCount: item.broadbandMembers,
              terminal5GCount: item.terminal5GMembers
            }
          });
          
          // 初始化筛选结果
          this.filterGroups(0);
        } else {
          uni.showToast({
            title: res.data.msg || '获取集团列表失败',
            icon: 'none'
          });
        }
        
        uni.hideLoading();
      }).catch(err => {
        console.error('获取集团列表出错：', err);
        uni.hideLoading();
        uni.showToast({
          title: '网络请求失败，请重试',
          icon: 'none'
        });
      });
    },
    
    // 获取集团详情
    getGroupDetail() {
      if (!this.selectedGroup) return;
      
      // 显示加载中
      this.loading = true;
      
      this.$http.sendRequest('zhanke/group_detail', 'POST', {
        groupCode: this.selectedGroup
      }).then(res => {
        this.loading = false;
        
        if (res.data && res.data.code === 200) {
          const detail = res.data.data;
          
          // 更新基础信息
          this.basicInfo = {
            totalCount: detail.totalMembers || 0,
            netCount: detail.networkMembers || 0,
            count5G: detail.members5G || 0,
            broadbandCount: detail.broadbandMembers || 0,
            terminal5GCount: detail.terminal5GMembers || 0
          };
          
          // 更新当前集团信息
          Object.assign(this.currentGroup, {
            manager: detail.manager,
            managerPhone: detail.managerPhone,
            industryChain: detail.industryChain,
            planDelivered: detail.planDelivered
          });
          
          // 更新模块状态
          this.updateModuleStatus();
        }
      }).catch(err => {
        this.loading = false;
        console.error('获取集团详情出错：', err);
        
        uni.showToast({
          title: '获取集团详情失败',
          icon: 'none'
        });
      });
    },

    // 根据关键字搜索
    onInput(e) {
      // 直接从事件对象中获取值，而不是e.detail
      let value = '';
      
      // 兼容不同类型的输入事件
      if (typeof e === 'string') {
        value = e;
      } else if (e && e.detail && e.detail.value !== undefined) {
        value = e.detail.value;
      } else if (e && e.target && e.target.value !== undefined) {
        value = e.target.value;
      } else if (e && typeof e === 'object') {
        value = e.value || '';
      }
      
      console.log('搜索框输入值:', value);
      
      // 更新搜索关键词
      this.searchKeyword = value;
      
      // 当输入框清空时，恢复显示所有集团
      if (!value) {
        this.searchKeyword = '';
        this.filterGroups(this.activeFilter);
        return;
      }
      
      // 延迟搜索，减少频繁请求
      if (this.searchTimer) {
        clearTimeout(this.searchTimer);
      }
      
      this.searchTimer = setTimeout(() => {
        console.log('执行延迟搜索，关键词:', this.searchKeyword);
        // 保持当前的行业筛选条件
        this.filterGroups(this.activeFilter, this.industryList[this.activeFilter]?.value);
      }, 300);
    },

    // 搜索提交
    onSearch() {
      console.log('触发搜索按钮，当前关键词:', this.searchKeyword);
      
      // 搜索关键词为空时不发起请求
      if (!this.searchKeyword || this.searchKeyword.trim() === '') {
        this.searchKeyword = '';
        this.filterGroups(this.activeFilter, this.industryList[this.activeFilter]?.value || '');
        return;
      }
      
      // 确保关键词被正确保存
      const keyword = this.searchKeyword.trim();
      
      // 强制更新searchKeyword以确保它被应用
      this.$nextTick(() => {
        this.searchKeyword = keyword;
        console.log('准备执行搜索，关键词:', this.searchKeyword);
        // 使用当前行业筛选条件执行搜索
        this.filterGroups(this.activeFilter, this.industryList[this.activeFilter]?.value || '');
      });
    },

    // 快速选择集团
    quickSelect(group) {
      try {
        // 判断传入的是对象还是编码值
        let code = typeof group === 'object' ? group.code : group;
        
        this.selectedGroup = code;
        
        // 从接口获取集团详情
        this.getGroupDetail();
        
        // 从本地列表中查找基本信息
        this.currentGroup = this.groupOptions.find(item => item.code === code) || {};
        
        // 清空搜索框
        this.searchKeyword = "";
        
        // 设置筛选对应行业
        const industry = this.currentGroup.industry;
        const industryIndex = this.industryList.findIndex(item => item.value === industry);
        
        if (industryIndex !== -1) {
          this.activeFilter = industryIndex;
        } else {
          this.activeFilter = 0; // 默认选择全部
        }
        
        this.filterGroups(this.activeFilter, industryIndex > 0 ? industry : '');
        
        // 选择完成后关闭弹窗
        setTimeout(() => {
          this.showGroupPopup = false;
        }, 100);
      } catch (e) {
        console.error('选择集团单位出错', e);
      }
    },
    
    // 获取行业徽章样式
    getBadgeClass(industry) {
      if (!industry) return 'badge-default';
      
      switch(industry) {
        case '政府机构':
        case '党政':
        case '公检法':
          return 'badge-government';
        case '教育':
        case '科教':
          return 'badge-education';
        case '医疗':
        case '医卫':
          return 'badge-medical';
        case '创新':
          return 'badge-innovation';
        case '融合':
          return 'badge-fusion';
        case '金融':
          return 'badge-finance';
        case '交通':
          return 'badge-transport';
        case '工业能源':
          return 'badge-industry';
        case '农商':
          return 'badge-agriculture';
        default:
          return 'badge-default';
      }
    },

    // 选择集团
    selectGroup(group) {
      if (!group) return;
      
      try {
        // 获取集团编码
        const code = group.code;
        if (!code) return;
        
        // 更新选中集团
        this.selectedGroup = code;
        this.currentGroup = this.groupOptions.find(item => item.code === code) || group;
        
        // 获取集团详情
        this.getGroupDetail();
        
        // 关闭弹窗
        this.showGroupPopup = false;
        
        // 提示选择成功
        uni.showToast({
          title: '已选择: ' + (this.currentGroup.name || this.currentGroup.label),
          icon: 'none',
          duration: 1500
        });
      } catch (e) {
        console.error('选择集团单位失败:', e);
      }
    },

    // 点击遮罩层关闭弹窗
    onMaskClick() {
      this.showGroupPopup = false;
    },

    // 获取行业列表
    getIndustryList() {
      // 显示加载中
      uni.showLoading({
        title: '加载中...'
      });



      // 请求行业列表接口
      this.$http.sendRequest('zhanke/industry_list', 'POST', {}).then(res => {
        //成功回调
        console.log('请求结果', res);
        var data = res.data.data;
        if (res.data.code == 200) {
          uni.hideLoading();
          this.loading = false;

          const list = res.data.data || [];
            
            // 将接口返回的数据格式化为组件需要的格式
            if (list.length > 0) {
              // 插入"全部"选项
              this.industryList = [
                { label: '全部', value: '' },
                ...list.map(item => ({
                  label: item.name,
                  value: item.name
                }))
              ];
            }
    
        } else {
          uni.hideLoading();
          this.loading = false;
          console.log('获取行业列表失败，使用默认数据');
          // 使用默认数据
        }
      }).catch(err => {
        //请求失败
        uni.hideLoading(); // 确保加载提示被关闭
        this.loading = false;
        
        uni.showToast({
          icon: "error",
          title: err.errMsg || '网络请求失败',
          duration: 2000 //时间
        });
      });
    },
    
    // 更新模块状态
    updateModuleStatus() {
      // 如果没有选择集团，所有模块都显示为未完善
      if (!this.selectedGroup) {
        this.moduleStatus = {
          basicInfo: false,
          memberFollow: false,
          itExpansion: false
        };
        return;
      }
      
      // 判断基础信息是否完善
      this.moduleStatus.basicInfo = this.hasBasicInfo;
      
      // 获取成员跟进记录和产品拓展记录，并据此判断模块状态
      this.checkMemberFollowStatus();
      this.checkITExpansionStatus();
    },
    
    // 检查成员跟进模块状态
    checkMemberFollowStatus() {
      if (!this.selectedGroup) return;
      
      // 获取成员跟进记录
      this.$http.sendRequest('zhanke/member_follow_list', 'POST', {
        groupCode: this.selectedGroup,
        page: 1,
        limit: 1 // 只需要检查是否有记录，获取一条即可
      }).then(res => {
        if (res.data && res.data.code === 200) {
          const list = res.data.data.list || [];
          // 有一条记录即为已完善
          this.moduleStatus.memberFollow = list.length > 0;
        } else {
          this.moduleStatus.memberFollow = false;
        }
      }).catch(err => {
        console.error('获取成员跟进记录出错：', err);
        this.moduleStatus.memberFollow = false;
      });
    },
    
    // 检查信息化拓展模块状态
    checkITExpansionStatus() {
      if (!this.selectedGroup) return;
      
      // 获取产品拓展记录
      this.$http.sendRequest('zhanke/expansion_list', 'POST', {
        groupCode: this.selectedGroup,
        page: 1,
        limit: 1 // 只需要检查是否有记录，获取一条即可
      }).then(res => {
        if (res.data && res.data.code === 200) {
          const list = res.data.data.list || [];
          // 有一条记录即为已完善
          this.moduleStatus.itExpansion = list.length > 0;
        } else {
          this.moduleStatus.itExpansion = false;
        }
      }).catch(err => {
        console.error('获取产品拓展记录出错：', err);
        this.moduleStatus.itExpansion = false;
      });
    },
    
    // 获取模块状态（从接口获取各模块的完善状态）
    getModuleStatus() {
      // 这里假设有一个接口可以获取模块状态
      // 实际使用时根据API文档对接相应接口
      this.$http.sendRequest('zhanke/incomplete', 'POST', {}).then(res => {
        if (res.data && res.data.code === 200) {
          // 假设接口返回了当前集团的信息
          const incompleteGroups = res.data.data || [];
          
          // 查找当前集团是否在未完善列表中
          const currentGroupIncomplete = incompleteGroups.find(
            item => item.groupCode === this.currentGroup.code
          );
          
          if (currentGroupIncomplete) {
            // 如果在未完善列表中，则根据返回的信息更新状态
            this.moduleStatus.basicInfo = currentGroupIncomplete.hasBasicInfo;
            
            // 我们将在单独的接口中获取成员跟进和信息化拓展状态，这里不再更新这两项
            // 改为调用专门的检查方法
            this.checkMemberFollowStatus();
            this.checkITExpansionStatus();
          }
        }
      }).catch(err => {
        console.error('获取模块状态出错：', err);
        // 出错时使用专门的检查方法获取状态
        this.checkMemberFollowStatus();
        this.checkITExpansionStatus();
      });
    }
  }
};
</script>

<style>
.business-container {
  min-height: 100vh;
  background-color: #f8f9fc;
  padding-bottom: 30px;
  width: 100%;
  box-sizing: border-box;
}

/* 头部样式 */
.page-header {
  background: linear-gradient(135deg, #007aff, #1546a3);
  padding: 60px 20px 20px;
  color: #ffffff;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  z-index: 10;
  width: 100%;
  box-sizing: border-box;
}

.header-content {
  position: relative;
  z-index: 5;
}

.page-title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 14px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.select-group-btn {
  display: flex;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  width: fit-content;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.select-group-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.select-group-btn text {
  flex: 1;
  margin-right: 8px;
}

/* 波浪背景 */
.wave-box {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40px;
  overflow: hidden;
}

.wave {
  position: absolute;
  bottom: -20px;
  left: 0;
  width: 200%;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 100% 100% 0 0;
}

.wave-1 {
  animation: wave-animation 8s linear infinite;
  height: 30px;
  opacity: 0.5;
}

.wave-2 {
  animation: wave-animation 10s linear infinite;
  height: 25px;
  bottom: -15px;
  opacity: 0.3;
  animation-delay: 0.5s;
}

@keyframes wave-animation {
  0% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-25%);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* 内容区域 */
.content-area {
  padding: 15px;
  width: 100%;
  box-sizing: border-box;
}

/* 集团信息卡片 */
.group-info-card {
  background-color: #ffffff;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 5px 20px 0 rgba(43, 86, 154, 0.06);
  transition: all 0.3s ease;
  width: 100%;
  box-sizing: border-box;
}

.group-info-card:hover {
  box-shadow: 0 8px 25px 0 rgba(43, 86, 154, 0.1);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.card-title {
  display: flex;
  align-items: center;
}

.card-title text {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin-left: 10px;
}

.card-badge {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 12px;
  color: #fff;
  font-weight: 500;
}

.badge-government {
  background: linear-gradient(135deg, #007aff, #1546a3);
  box-shadow: 0 3px 6px rgba(0, 122, 255, 0.2);
}

.badge-education {
  background: linear-gradient(135deg, #19be6b, #078d4b);
  box-shadow: 0 3px 6px rgba(25, 190, 107, 0.2);
}

.badge-medical {
  background: linear-gradient(135deg, #ff9900, #d17a00);
  box-shadow: 0 3px 6px rgba(255, 153, 0, 0.2);
}

.badge-innovation {
  background: linear-gradient(135deg, #8a2be2, #4b0082);
  box-shadow: 0 3px 6px rgba(138, 43, 226, 0.2);
}

.badge-fusion {
  background: linear-gradient(135deg, #00bcd4, #006064);
  box-shadow: 0 3px 6px rgba(0, 188, 212, 0.2);
}

.badge-finance {
  background: linear-gradient(135deg, #f44336, #b71c1c);
  box-shadow: 0 3px 6px rgba(244, 67, 54, 0.2);
}

.badge-transport {
  background: linear-gradient(135deg, #3f51b5, #1a237e);
  box-shadow: 0 3px 6px rgba(63, 81, 181, 0.2);
}

.badge-industry {
  background: linear-gradient(135deg, #795548, #3e2723);
  box-shadow: 0 3px 6px rgba(121, 85, 72, 0.2);
}

.badge-agriculture {
  background: linear-gradient(135deg, #4caf50, #1b5e20);
  box-shadow: 0 3px 6px rgba(76, 175, 80, 0.2);
}

.badge-default {
  background: linear-gradient(135deg, #909399, #606266);
  box-shadow: 0 3px 6px rgba(144, 147, 153, 0.2);
}

.info-grid {
  background-color: #f9fafc;
  border-radius: 12px;
  padding: 15px;
}

.info-row {
  display: flex;
  margin-bottom: 12px;
}

.info-row:last-child {
  margin-bottom: 0;
}

.info-item {
  flex: 1;
}

.info-label {
  display: block;
  font-size: 12px;
  color: #909399;
  margin-bottom: 6px;
}

.info-value {
  display: block;
  font-size: 15px;
  color: #333;
  font-weight: 500;
}

/* 未选择集团提示 */
.empty-notice-container {
  height: 220px;
}

.empty-notice-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  height: 100%;
}

.empty-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-image {
  width: 100px;
  height: 100px;
  margin-bottom: 15px;
}

.empty-text {
  font-size: 16px;
  color: #909399;
  margin-bottom: 20px;
}

.select-btn {
  background: linear-gradient(135deg, #007aff, #1546a3);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 16px;
  box-shadow: 0 5px 15px rgba(0, 122, 255, 0.2);
  transition: all 0.3s ease;
}

.select-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 5px rgba(0, 122, 255, 0.2);
}

/* 三个业务模块卡片 */
.module-list {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
  background-color: #ffffff;
  border-radius: 16px;
  padding: 5px;
  box-shadow: 0 5px 20px 0 rgba(43, 86, 154, 0.06);
  width: 100%;
  box-sizing: border-box;
}

.module-item {
  display: flex;
  align-items: center;
  padding: 20px 15px;
  margin-bottom: 10px;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.module-item:last-child {
  margin-bottom: 0;
}

.module-item:active {
  background-color: #f8f9fc;
  transform: scale(0.98);
}

.module-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.module-info {
  flex: 1;
}

.module-title {
  font-size: 18px;
  font-weight: 600;
  color: #333333;
  margin-bottom: 6px;
}

.module-desc {
  font-size: 14px;
  color: #909399;
}

.item-right {
  display: flex;
  align-items: center;
}

.status-tag {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  margin-right: 10px;
}

.status-complete {
  background-color: #e8f5e9;
  color: #4caf50;
}

.status-incomplete {
  background-color: #fff8e1;
  color: #ff9800;
}

.module-icon-blue {
  background: linear-gradient(135deg, #29b6f6, #1976d2);
}

.module-icon-green {
  background: linear-gradient(135deg, #66bb6a, #388e3c);
}

.module-icon-orange {
  background: linear-gradient(135deg, #ffa726, #ef6c00);
}

/* 集团弹窗 */
.custom-popup-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  display: flex;
  align-items: flex-end;
  transition: all 0.3s;
  width: 100%;
}

.custom-popup {
  width: 100%;
  height: 80vh;
  background-color: #fff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  overflow: hidden;
  position: relative;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.popup-content-wrap {
  padding: 25px 20px;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  box-sizing: border-box;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.popup-title {
  font-size: 20px;
  font-weight: bold;
  color: #333;
}

.popup-close-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: #f5f7fa;
}

.popup-search-box {
  margin-bottom: 15px;
}

.popup-tabs {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  background-color: #f5f7fa;
  border-radius: 12px;
  padding: 4px;
}

.popup-tab-item {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 14px;
  color: #606266;
  border-radius: 10px;
  transition: all 0.3s;
  margin: 0 2px;
}

.popup-tab-active {
  background-color: #007aff;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 122, 255, 0.3);
}

.popup-scroll-view {
  flex: 1;
  overflow-y: auto;
}

.popup-list-title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin: 15px 0 10px;
  display: flex;
  align-items: center;
}

.popup-list-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: #ebeef5;
  margin-left: 10px;
}

.popup-group-list {
  background-color: #f9fafc;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.03);
}

.popup-group-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #eeeeee;
  transition: all 0.2s ease;
}

.popup-group-item:active {
  background-color: #f0f5ff;
}

.popup-group-item.selected {
  background-color: #f0f5ff;
}

.popup-group-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.popup-group-name {
  font-size: 16px;
  color: #333;
  font-weight: 500;
  margin-bottom: 4px;
}

.popup-group-code {
  font-size: 13px;
  color: #909399;
}

.popup-empty {
  padding: 30px 0;
}

.selected-indicator {
  color: #007aff;
  font-weight: 500;
}

/* 动画 */
.animate-scale-up {
  animation: scaleUp 0.5s ease forwards;
}

@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-slide-up {
  animation: slideUpAnimation 0.5s ease forwards;
  animation-delay: 0.2s;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes slideUpAnimation {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
</style>